//
//  DesignViewController.m
//  FuncFanc
//
//  Created by hubing on 2018/9/13.
//  Copyright © 2018年 huhu. All rights reserved.
//

#import "DesignViewController.h"
#import "FontViewController.h"
#import "UserRecordViewController.h"
#import "CardRecordViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "MusicPlayViewController.h"
#import "PoetryViewController.h"

@interface DesignViewController ()<UITableViewDataSource,UITableViewDelegate,AVAudioPlayerDelegate>
@property (nonatomic,strong) UITableView *tableview;
@property (nonatomic,strong) NSArray *dataList;

@property (nonatomic,strong) AVAudioPlayer *audioPlayer;

@end

@implementation DesignViewController

-(UITableView *)tableview{
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        [self.view addSubview:_tableview];
    }
    return _tableview;
}

-(NSArray *)dataList{
    if (!_dataList) {
        _dataList = [NSArray array];
    }
    return _dataList;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dataList = @[@"字体",@"用户",@"卡片",@"音乐",@"写诗",@"对酒"];
    [self.tableview reloadData];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataList.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%@",self.dataList[indexPath.row]];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *title = self.dataList[indexPath.row];
    if ([title isEqualToString:@"字体"])
    {
        FontViewController *fontVC = [[FontViewController alloc]init];
        fontVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:fontVC animated:YES];
    }
    else if([title isEqualToString:@"用户"])
    {
        UserRecordViewController *userVC = [[UserRecordViewController alloc]init];
        userVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:userVC animated:YES];
    }
    else if([title isEqualToString:@"卡片"])
    {
        CardRecordViewController *cardVC = [[CardRecordViewController alloc]init];
        cardVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:cardVC animated:YES];
    }
    else if([title isEqualToString:@"音乐"])
    {
        MusicPlayViewController *musicVc = [[MusicPlayViewController alloc]init];
        musicVc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:musicVc animated:YES];
    }
    else if([title isEqualToString:@"写诗"])
    {
        MyWebViewController *webvc = [[MyWebViewController alloc]initWithTitle:@"AI写诗" andUrl:@"https://www.mindspore.cn/resources/tech/nlp/poetry"];
        webvc.modalPresentationStyle = UIModalPresentationFullScreen;
        webvc.hidesBottomBarWhenPushed = YES;
//        webvc.recogizerBlock = ^(NSString *codeStr) {
//
//            NSString *print = [NSString stringWithFormat:@"二维码内容：%@",codeStr];
//            [HUDHelper alert:print];
//        };

        [self.navigationController pushViewController:webvc animated:YES];
//        [self presentViewController:webvc animated:YES completion:nil];
        
        
    }
    else if([title isEqualToString:@"对酒"])
    {
        PoetryViewController *view = [[PoetryViewController alloc]init];
        view.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:view animated:YES];
    }

}





@end
